##
## Makefile for  in /home/monpie_l//Projets/Cpp/Babel
## 
## Made by lisa monpierre
## Login   <monpie_l@epitech.net>
## 
## Started on  Wed May  9 01:49:37 2012 lisa monpierre
## Last update Tue May 15 02:41:17 2012 lisa monpierre
##

## -----------------------------------------------------------------------------
## Compilation -----------------------------------------------------------------

CLT_TCP	=	clientTcp
SVR_TCP	=	serveurTcp
CLT_UDP	=	clientUdp
SVR_UDP	=	serveurUdp

CXX	=	g++

RM	=	rm -f

SEV	=	-Wall -Werror -Wextra -ansi -pedantic

DEBUG	=	-ggdb -D__DEBUG__

CXXFLAG	= $(SEV) $(DEBUG)

## -----------------------------------------------------------------------------
## Sources ---------------------------------------------------------------------

SRC_CLT_TCP_F	=	ClientTcp.cpp\
			main.cpp

SRC_CLT_UDP_F	=	ClientUdp.cpp\
			main.cpp

SRC_CM_F	=	Buffer.cpp\
			UdpUnix.cpp\
			Connected.cpp\
			SockInfo.cpp\
			Control.cpp\
			TcpUnix.cpp\
			FdInfos.cpp\
			TimeVal.cpp\
			ACommunicator.cpp

SRC_SVR_TCP_F	=	ServerTcp.cpp\
			main.cpp

SRC_SVR_UDP_F	=	ServerUdp.cpp\
			main.cpp

SRC_CLT_UDP	=	$(addprefix ./src/client/udp/, $(SRC_CLT_UDP_F))
SRC_SVR_UDP	=	$(addprefix ./src/server/udp/, $(SRC_SVR_UDP_F))
SRC_CLT_TCP	=	$(addprefix ./src/client/tcp/, $(SRC_CLT_TCP_F))
SRC_SVR_TCP	=	$(addprefix ./src/server/tcp/, $(SRC_SVR_TCP_F))
SRC_CM	=	$(addprefix ./src/common/, $(SRC_CM_F))

## -----------------------------------------------------------------------------
## Objects ---------------------------------------------------------------------

OBJS_CLT_UDP	=	$(SRC_CLT_UDP:.cpp=.o)
OBJS_SVR_UDP	=	$(SRC_SVR_UDP:.cpp=.o)
OBJS_CLT_TCP	=	$(SRC_CLT_TCP:.cpp=.o)
OBJS_SVR_TCP	=	$(SRC_SVR_TCP:.cpp=.o)
OBJS_CM		=	$(SRC_CM:.cpp=.o)

## -----------------------------------------------------------------------------
## Library ---------------------------------------------------------------------

ICL	=	-I./include/

## -----------------------------------------------------------------------------
## Rules -----------------------------------------------------------------------

all: $(CLT_TCP) $(SVR_TCP) $(CLT_UDP) $(SVR_UDP)

$(SVR_UDP): $(OBJS_SVR_UDP) $(OBJS_CM)
	$(CXX)  -o $(SVR_UDP) $(OBJS_SVR_UDP) $(OBJS_CM)

$(CLT_UDP): $(OBJS_CLT_UDP) $(OBJS_CM)
	$(CXX)  -o $(CLT_UDP) $(OBJS_CLT_UDP) $(OBJS_CM)

$(SVR_TCP): $(OBJS_SVR_TCP) $(OBJS_CM)
	$(CXX)  -o $(SVR_TCP) $(OBJS_SVR_TCP) $(OBJS_CM)

$(CLT_TCP): $(OBJS_CLT_TCP) $(OBJS_CM)
	$(CXX)  -o $(CLT_TCP) $(OBJS_CLT_TCP) $(OBJS_CM)

.cpp.o:
	$(CXX) -c $< -o $@ $(ICL) $(CXXFLAG)

clean:
	$(RM) $(OBJS_CLT_UDP)
	$(RM) $(OBJS_SVR_UDP)
	$(RM) $(OBJS_CLT_TCP)
	$(RM) $(OBJS_SVR_TCP)
	$(RM) $(OBJS_CM)
	find . -name "*~" -delete

fclean: clean
	$(RM) $(SVR_TCP)
	$(RM) $(CLT_TCP)
	$(RM) $(SVR_UDP)
	$(RM) $(CLT_UDP)

re: fclean all

.PHONY: all clean fclean re
